package com.cxs.dao.sys.impl;

import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.cxs.dao.DAOFactory;
import com.cxs.dao.sys.UserDAO;
import com.cxs.model.sys.Sys_User;

@Repository
public class UserDAOImpl extends DAOFactory implements UserDAO{

	public Integer countUser(Map<String, Object> paramMap) {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT COUNT(1)");
		sql.append(" FROM c_sys_user t");
		sql.append(" WHERE company_no=:company_no");
		return namedParameterJdbcTemplate.queryForObject(sql.toString(),paramMap,Integer.class);
	}

	public List<Sys_User> listUser(Map<String, Object> paramMap) {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT id,user_name,");
		sql.append(" user_no,user_account,phone,");
		sql.append(" address,is_use,role_no,company_no");
		sql.append(" FROM c_sys_user t");
		sql.append(" WHERE company_no=:company_no");
		return namedParameterJdbcTemplate.query(sql.toString(), paramMap ,
				new BeanPropertyRowMapper<>(Sys_User.class));
	}

}
